home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / DatabaseAccess.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  12.5 KB  |  353 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        DatabaseAccess.p
  3.  
  4.      Contains:    Database Access Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1989-1998, 1995-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT DatabaseAccess;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __DATABASEACCESS__}
  28. {$SETC __DATABASEACCESS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC DatabaseAccessIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __RESOURCES__}
  35. {$I Resources.p}
  36. {$ENDC}
  37.  
  38.  
  39. {$PUSH}
  40. {$ALIGN MAC68K}
  41. {$LibExport+}
  42.  
  43. { data type codes }
  44.  
  45. CONST
  46.     typeNone                    = 'none';
  47.     typeDate                    = 'date';
  48.     typeTime                    = 'time';
  49.     typeTimeStamp                = 'tims';
  50.     typeDecimal                    = 'deci';
  51.     typeMoney                    = 'mone';
  52.     typeVChar                    = 'vcha';
  53.     typeVBin                    = 'vbin';
  54.     typeLChar                    = 'lcha';
  55.     typeLBin                    = 'lbin';
  56.     typeDiscard                    = 'disc';                        {  "dummy" types for DBResultsToText  }
  57.     typeUnknown                    = 'unkn';
  58.     typeColBreak                = 'colb';
  59.     typeRowBreak                = 'rowb';                        {  pass this in to DBGetItem for any data type  }
  60.     typeAnyType                    = 0;
  61.  
  62. { infinite timeout value for DBGetItem }
  63.                                                                 {  messages for status functions for DBStartQuery  }
  64.     kDBUpdateWind                = 0;
  65.     kDBAboutToInit                = 1;
  66.     kDBInitComplete                = 2;
  67.     kDBSendComplete                = 3;
  68.     kDBExecComplete                = 4;
  69.     kDBStartQueryComplete        = 5;
  70.  
  71.                                                                 {  messages for status functions for DBGetQueryResults  }
  72.     kDBGetItemComplete            = 6;
  73.     kDBGetQueryResultsComplete    = 7;
  74.     kDBWaitForever                = -1;
  75.  
  76.                                                                 {   flags for DBGetItem   }
  77.     kDBLastColFlag                = $0001;
  78.     kDBNullFlag                    = $0004;
  79.  
  80.  
  81. TYPE
  82.     DBType                                = OSType;
  83.     DBAsyncParamBlockRecPtr = ^DBAsyncParamBlockRec;
  84.     DBAsyncParmBlkPtr                    = ^DBAsyncParamBlockRec;
  85. {$IFC TYPED_FUNCTION_POINTERS}
  86.     DBCompletionProcPtr = PROCEDURE(pb: DBAsyncParmBlkPtr);
  87. {$ELSEC}
  88.     DBCompletionProcPtr = Register68kProcPtr;
  89. {$ENDC}
  90.  
  91.     DBCompletionUPP = UniversalProcPtr;
  92. { structure for asynchronous parameter block }
  93.     DBAsyncParamBlockRec = RECORD
  94.         completionProc:            DBCompletionUPP;                        {  pointer to completion routine  }
  95.         result:                    OSErr;                                    {  result of call  }
  96.         userRef:                LONGINT;                                {  for application's use  }
  97.         ddevRef:                LONGINT;                                {  for ddev's use  }
  98.         reserved:                LONGINT;                                {  for internal use  }
  99.     END;
  100.  
  101. { structure for resource list in QueryRecord }
  102.     ResListElemPtr = ^ResListElem;
  103.     ResListElem = RECORD
  104.         theType:                ResType;                                {  resource type  }
  105.         id:                        INTEGER;                                {  resource id  }
  106.     END;
  107.  
  108.     ResListPtr                            = ^ResListElem;
  109.     ResListHandle                        = ^ResListPtr;
  110. { structure for query list in QueryRecord }
  111.     QueryArray                            = ARRAY [0..255] OF Handle;
  112.     QueryListPtr                        = ^QueryArray;
  113.     QueryListHandle                        = ^QueryListPtr;
  114.     QueryRecordPtr = ^QueryRecord;
  115.     QueryRecord = RECORD
  116.         version:                INTEGER;                                {  version  }
  117.         id:                        INTEGER;                                {  id of 'qrsc' this came from  }
  118.         queryProc:                Handle;                                    {  handle to query def proc  }
  119.         ddevName:                Str63;                                    {  ddev name  }
  120.         host:                    Str255;                                    {  host name  }
  121.         user:                    Str255;                                    {  user name  }
  122.         password:                Str255;                                    {  password  }
  123.         connStr:                Str255;                                    {  connection string  }
  124.         currQuery:                INTEGER;                                {  index of current query  }
  125.         numQueries:                INTEGER;                                {  number of queries in list  }
  126.         queryList:                QueryListHandle;                        {  handle to array of handles to text  }
  127.         numRes:                    INTEGER;                                {  number of resources in list  }
  128.         resList:                ResListHandle;                            {  handle to array of resource list elements  }
  129.         dataHandle:                Handle;                                    {  for use by query def proc  }
  130.         refCon:                    LONGINT;                                {  for use by application  }
  131.     END;
  132.  
  133.     QueryPtr                            = ^QueryRecord;
  134.     QueryHandle                            = ^QueryPtr;
  135. { structure of column types array in ResultsRecord }
  136.     ColTypesArray                        = ARRAY [0..255] OF DBType;
  137.     ColTypesPtr                            = ^ColTypesArray;
  138.     ColTypesHandle                        = ^ColTypesPtr;
  139. { structure for column info in ResultsRecord }
  140.     DBColInfoRecordPtr = ^DBColInfoRecord;
  141.     DBColInfoRecord = RECORD
  142.         len:                    INTEGER;
  143.         places:                    INTEGER;
  144.         flags:                    INTEGER;
  145.     END;
  146.  
  147.     ColInfoArray                        = ARRAY [0..255] OF DBColInfoRecord;
  148.     ColInfoPtr                            = ^ColInfoArray;
  149.     ColInfoHandle                        = ^ColInfoPtr;
  150. { structure of results returned by DBGetResults }
  151.     ResultsRecordPtr = ^ResultsRecord;
  152.     ResultsRecord = RECORD
  153.         numRows:                INTEGER;                                {  number of rows in result  }
  154.         numCols:                INTEGER;                                {  number of columns per row  }
  155.         colTypes:                ColTypesHandle;                            {  data type array  }
  156.         colData:                Handle;                                    {  actual results  }
  157.         colInfo:                ColInfoHandle;                            {  DBColInfoRecord array  }
  158.     END;
  159.  
  160.  
  161. CONST
  162.                                                                 {  messages sent to a 'ddev' }
  163.     kDBInit                        = 0;
  164.     kDBEnd                        = 1;
  165.     kDBGetConnInfo                = 2;
  166.     kDBGetSessionNum            = 3;
  167.     kDBSend                        = 4;
  168.     kDBSendItem                    = 5;
  169.     kDBExec                        = 6;
  170.     kDBState                    = 7;
  171.     kDBGetErr                    = 8;
  172.     kDBBreak                    = 9;
  173.     kDBGetItem                    = 10;
  174.     kDBUngetItem                = 11;
  175.     kDBKill                        = 12;
  176.     kDBOpen                        = 100;
  177.     kDBClose                    = 101;
  178.     kDBIdle                        = 102;
  179.  
  180.  
  181. TYPE
  182. {$IFC TYPED_FUNCTION_POINTERS}
  183.     DBQueryDefProcPtr = FUNCTION(VAR sessID: LONGINT; query: QueryHandle): OSErr;
  184. {$ELSEC}
  185.     DBQueryDefProcPtr = ProcPtr;
  186. {$ENDC}
  187.  
  188. {$IFC TYPED_FUNCTION_POINTERS}
  189.     DBStatusProcPtr = FUNCTION(message: INTEGER; result: OSErr; dataLen: INTEGER; dataPlaces: INTEGER; dataFlags: INTEGER; dataType: DBType; dataPtr: Ptr): BOOLEAN;
  190. {$ELSEC}
  191.     DBStatusProcPtr = ProcPtr;
  192. {$ENDC}
  193.  
  194. {$IFC TYPED_FUNCTION_POINTERS}
  195.     DBResultHandlerProcPtr = FUNCTION(dataType: DBType; theLen: INTEGER; thePlaces: INTEGER; theFlags: INTEGER; theData: Ptr; theText: Handle): OSErr;
  196. {$ELSEC}
  197.     DBResultHandlerProcPtr = ProcPtr;
  198. {$ENDC}
  199.  
  200.     DBQueryDefUPP = UniversalProcPtr;
  201.     DBStatusUPP = UniversalProcPtr;
  202.     DBResultHandlerUPP = UniversalProcPtr;
  203.  
  204. CONST
  205.     uppDBCompletionProcInfo = $0000B802;
  206.     uppDBQueryDefProcInfo = $000003E0;
  207.     uppDBStatusProcInfo = $000FAA90;
  208.     uppDBResultHandlerProcInfo = $0003EAE0;
  209.  
  210. FUNCTION NewDBCompletionProc(userRoutine: DBCompletionProcPtr): DBCompletionUPP;
  211.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  212.     INLINE $2E9F;
  213.     {$ENDC}
  214.  
  215. FUNCTION NewDBQueryDefProc(userRoutine: DBQueryDefProcPtr): DBQueryDefUPP;
  216.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  217.     INLINE $2E9F;
  218.     {$ENDC}
  219.  
  220. FUNCTION NewDBStatusProc(userRoutine: DBStatusProcPtr): DBStatusUPP;
  221.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  222.     INLINE $2E9F;
  223.     {$ENDC}
  224.  
  225. FUNCTION NewDBResultHandlerProc(userRoutine: DBResultHandlerProcPtr): DBResultHandlerUPP;
  226.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  227.     INLINE $2E9F;
  228.     {$ENDC}
  229.  
  230. PROCEDURE CallDBCompletionProc(pb: DBAsyncParmBlkPtr; userRoutine: DBCompletionUPP);
  231.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  232.     {To be implemented:  Glue to move parameters into registers.}
  233.     {$ENDC}
  234.  
  235. FUNCTION CallDBQueryDefProc(VAR sessID: LONGINT; query: QueryHandle; userRoutine: DBQueryDefUPP): OSErr;
  236.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  237.     INLINE $205F, $4E90;
  238.     {$ENDC}
  239.  
  240. FUNCTION CallDBStatusProc(message: INTEGER; result: OSErr; dataLen: INTEGER; dataPlaces: INTEGER; dataFlags: INTEGER; dataType: DBType; dataPtr: Ptr; userRoutine: DBStatusUPP): BOOLEAN;
  241.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  242.     INLINE $205F, $4E90;
  243.     {$ENDC}
  244.  
  245. FUNCTION CallDBResultHandlerProc(dataType: DBType; theLen: INTEGER; thePlaces: INTEGER; theFlags: INTEGER; theData: Ptr; theText: Handle; userRoutine: DBResultHandlerUPP): OSErr;
  246.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  247.     INLINE $205F, $4E90;
  248.     {$ENDC}
  249. FUNCTION InitDBPack: OSErr;
  250.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  251.     INLINE $3F3C, $0004, $303C, $0100, $A82F;
  252.     {$ENDC}
  253. FUNCTION DBInit(VAR sessID: LONGINT; ddevName: Str63; host: Str255; user: Str255; passwd: Str255; connStr: Str255; asyncPB: DBAsyncParmBlkPtr): OSErr;
  254.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  255.     INLINE $303C, $0E02, $A82F;
  256.     {$ENDC}
  257. FUNCTION DBEnd(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  258.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  259.     INLINE $303C, $0403, $A82F;
  260.     {$ENDC}
  261. FUNCTION DBGetConnInfo(sessID: LONGINT; sessNum: INTEGER; VAR returnedID: LONGINT; VAR version: LONGINT; VAR ddevName: Str63; VAR host: Str255; VAR user: Str255; VAR network: Str255; VAR connStr: Str255; VAR start: LONGINT; VAR state: OSErr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  262.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  263.     INLINE $303C, $1704, $A82F;
  264.     {$ENDC}
  265. FUNCTION DBGetSessionNum(sessID: LONGINT; VAR sessNum: INTEGER; asyncPB: DBAsyncParmBlkPtr): OSErr;
  266.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  267.     INLINE $303C, $0605, $A82F;
  268.     {$ENDC}
  269. FUNCTION DBSend(sessID: LONGINT; text: Ptr; len: INTEGER; asyncPB: DBAsyncParmBlkPtr): OSErr;
  270.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  271.     INLINE $303C, $0706, $A82F;
  272.     {$ENDC}
  273. FUNCTION DBSendItem(sessID: LONGINT; dataType: DBType; len: INTEGER; places: INTEGER; flags: INTEGER; buffer: UNIV Ptr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  274.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  275.     INLINE $303C, $0B07, $A82F;
  276.     {$ENDC}
  277. FUNCTION DBExec(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  278.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  279.     INLINE $303C, $0408, $A82F;
  280.     {$ENDC}
  281. FUNCTION DBState(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  282.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  283.     INLINE $303C, $0409, $A82F;
  284.     {$ENDC}
  285. FUNCTION DBGetErr(sessID: LONGINT; VAR err1: LONGINT; VAR err2: LONGINT; VAR item1: Str255; VAR item2: Str255; VAR errorMsg: Str255; asyncPB: DBAsyncParmBlkPtr): OSErr;
  286.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  287.     INLINE $303C, $0E0A, $A82F;
  288.     {$ENDC}
  289. FUNCTION DBBreak(sessID: LONGINT; abort: BOOLEAN; asyncPB: DBAsyncParmBlkPtr): OSErr;
  290.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  291.     INLINE $303C, $050B, $A82F;
  292.     {$ENDC}
  293. FUNCTION DBGetItem(sessID: LONGINT; timeout: LONGINT; VAR dataType: DBType; VAR len: INTEGER; VAR places: INTEGER; VAR flags: INTEGER; buffer: UNIV Ptr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  294.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  295.     INLINE $303C, $100C, $A82F;
  296.     {$ENDC}
  297. FUNCTION DBUnGetItem(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  298.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  299.     INLINE $303C, $040D, $A82F;
  300.     {$ENDC}
  301. FUNCTION DBKill(asyncPB: DBAsyncParmBlkPtr): OSErr;
  302.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  303.     INLINE $303C, $020E, $A82F;
  304.     {$ENDC}
  305. FUNCTION DBGetNewQuery(queryID: INTEGER; VAR query: QueryHandle): OSErr;
  306.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  307.     INLINE $303C, $030F, $A82F;
  308.     {$ENDC}
  309. FUNCTION DBDisposeQuery(query: QueryHandle): OSErr;
  310.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  311.     INLINE $303C, $0210, $A82F;
  312.     {$ENDC}
  313. FUNCTION DBStartQuery(VAR sessID: LONGINT; query: QueryHandle; statusProc: DBStatusUPP; asyncPB: DBAsyncParmBlkPtr): OSErr;
  314.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  315.     INLINE $303C, $0811, $A82F;
  316.     {$ENDC}
  317. FUNCTION DBGetQueryResults(sessID: LONGINT; VAR results: ResultsRecord; timeout: LONGINT; statusProc: DBStatusUPP; asyncPB: DBAsyncParmBlkPtr): OSErr;
  318.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  319.     INLINE $303C, $0A12, $A82F;
  320.     {$ENDC}
  321. FUNCTION DBResultsToText(VAR results: ResultsRecord; VAR theText: Handle): OSErr;
  322.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  323.     INLINE $303C, $0413, $A82F;
  324.     {$ENDC}
  325. FUNCTION DBInstallResultHandler(dataType: DBType; theHandler: DBResultHandlerUPP; isSysHandler: BOOLEAN): OSErr;
  326.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  327.     INLINE $303C, $0514, $A82F;
  328.     {$ENDC}
  329. FUNCTION DBRemoveResultHandler(dataType: DBType): OSErr;
  330.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  331.     INLINE $303C, $0215, $A82F;
  332.     {$ENDC}
  333. FUNCTION DBGetResultHandler(dataType: DBType; VAR theHandler: DBResultHandlerUPP; getSysHandler: BOOLEAN): OSErr;
  334.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  335.     INLINE $303C, $0516, $A82F;
  336.     {$ENDC}
  337. FUNCTION DBIdle: OSErr;
  338.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  339.     INLINE $303C, $00FF, $A82F;
  340.     {$ENDC}
  341.  
  342.  
  343. {$ALIGN RESET}
  344. {$POP}
  345.  
  346. {$SETC UsingIncludes := DatabaseAccessIncludes}
  347.  
  348. {$ENDC} {__DATABASEACCESS__}
  349.  
  350. {$IFC NOT UsingIncludes}
  351.  END.
  352. {$ENDC}
  353.